<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改岗位')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-equipment-edit" th:object="${equipment}">
			<input id="id" name="id" type="hidden" th:field="*{id}"/>
			<div class="form-group">
				<label class="col-sm-3 control-label">设备类型：</label>
				<div class="col-sm-8">
					<select name="equipmentType" class="form-control m-b" th:with="type=${@dict.getType('equipment_type')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{equipmentType}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">设备编号：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="equipmentNo" id="equipmentNo" th:field="*{equipmentNo}" required>
				</div>
			</div>

		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "equipment";
		
		$("#form-equipment-edit").validate({
			onkeyup: false,
			rules:{
				equipmentNo:{
					remote: {
		                url: prefix + "/checkEquipmentNoUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"id": function() {
							    return $("input[name='id']").val();
							},
		                	"equipmentNo" : function() {
		                        return $.common.trim($("#equipmentNo").val());
		                    }
		                }
		            }
				},
			},
			messages: {
				"equipmentNo": {
					remote: "设备编号已经存在！"
				}
		    },
		    focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/update", $('#form-equipment-edit').serialize());
	        }
	    }
	</script>
</body>
</html>
